# -*- coding: UTF-8 -*-
# 2023/11/26 23:29
from tkinter import PhotoImage as tk_PhotoImage

from PIL import Image
from PIL.ImageTk import PhotoImage as pil_PhotoImage


def set_pil_img(image_path: str, size):
    """
    根据提供的地址和尺寸,修改图像后返回对应btn_pil_PhotoImage,并给其他加上size和image_path属性
    """
    btn_img = Image.open(image_path)
    btn_img.thumbnail(size=size)

    btn_pil_PhotoImage = pil_PhotoImage(btn_img)
    setattr(btn_pil_PhotoImage, "file_dir", image_path)
    setattr(btn_pil_PhotoImage, "size", size)
    return btn_pil_PhotoImage


def set_tkimage(image_path, master):
    """
    根据提供的地址和尺寸,修改图像后返回对应btn_pil_PhotoImage,并给其他加上size和image_path属性
    """
    tk_image = tk_PhotoImage(file=image_path)
    master.icon_image = tk_image

    return tk_image
